package nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter;

import android.content.Context;
import android.support.v4.util.TimeUtils;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;
import ezy.lite.util.DateTime;
import ezy.lite.util.UI;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.adapter.ItemAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.JoinRecord;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Raffle;

/**
 * Created by Administrator on 2016/3/12 0012.
 */
public class JoinRecordAdapter extends ItemAdapter<JoinRecord, JoinRecordAdapter.JoinRecordHolder> {
    private Context context;

    public JoinRecordAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public JoinRecordHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new JoinRecordHolder(inflate(R.layout.item_join_record, parent));
    }

    @Override
    public void onBindViewHolder(JoinRecordHolder holder, int position) {
        JoinRecord item = getItem(position);
        holder.txtName.setText(item.name);
        UI.setTvHtml(holder.txtLuckyNum,R.string.join_record_lucky,item.number+"");
        holder.txtTime.setText(DateTime.toDateTimeMs(item.time));
        if(position==0){
            holder.imgMaozi.setVisibility(View.VISIBLE);
            holder.imgWinner.setVisibility(View.VISIBLE);
        }else{
            holder.imgMaozi.setVisibility(View.GONE);
            holder.imgWinner.setVisibility(View.GONE);
        }
    }


    static class JoinRecordHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        @BindView(R.id.txt_name)
        TextView txtName;
        @BindView(R.id.txt_luckynum)
        TextView txtLuckyNum;
        @BindView(R.id.txt_time)
        TextView txtTime;
        @BindView(R.id.img_avatar)
        CircleImageView imgAvatar;
        @BindView(R.id.img_maozi)
        ImageView imgMaozi;
        @BindView(R.id.img_winner)
        ImageView imgWinner;
        public JoinRecordHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {

        }
    }
}
